home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / check_wka.z / check_wka
Encoding:
Text File  |  1998-10-28  |  6.6 KB  |  171 lines

  1. #!/bin/sh
  2.  
  3. # Checks an doc workarea dir.  Here's the output headers...
  4. # Checking for .docs not in the Makefile...
  5. # Checking for missing .sgm files...
  6. # Checking for extra .sgm files...
  7. # Checking for possible other extra files/dirs...
  8. # Checking help references (this may take a moment)...
  9. # Checking for fig files in orig, but not in Makefile...
  10. # Checking for fig files in Makefile, but not in orig...
  11. # Checking for fig files in the Makefile, but not ref'd in valid .doc's...
  12. # Checking for figs in print, but not ref'd in valid .doc's...
  13. # Checking for files referenced in valid .doc's, but not in print/...
  14. # Checking for figs in online not ref'd in valid sgm's...
  15. # Checking for files referenced in valid sgm's, but not in online/... 
  16.  
  17. TMPDIR=${TMPDIR:=/usr/tmp}
  18.  
  19. # if there's a Makefile
  20. if [ ! -f Makefile ] ; then
  21.   echo "No Makefile, so can't check valid .docs"
  22. else
  23.  
  24.   # make list of book files in the Makefile
  25.   awk '/^BOOK_FILES/,/[^\\]$/' Makefile | sed 's/^BOOK_FILES *= *//' | sed s'/\\$//' | sed 's/EndPart//' > ${TMPDIR}/.book_files.$$
  26.  
  27.   # make list of valid sgm files from .book_files
  28.   for file in `cat ${TMPDIR}/.book_files.$$` ; do
  29.     sgmfile=`echo $file | sed 's/\.doc/\.sgm/g'`
  30.     echo $sgmfile >> ${TMPDIR}/.valid_sgm_files.$$
  31.   done
  32.   valid_sgm_files=`cat ${TMPDIR}/.valid_sgm_files.$$` 
  33.  
  34.   # if there are any files listed in the Makefile
  35.   if [ ! -s ${TMPDIR}/.book_files.$$ -o -z "`grep doc ${TMPDIR}/.book_files.$$`" ] ; then 
  36.     echo "No .doc's on BOOK_FILES line in Makefile, checking sgm's...\n"
  37.   else
  38.  
  39.     echo "Checking for .docs not in the Makefile..."
  40.     for file in `/bin/ls *.doc` ; do
  41.       docfile=`basename $file`
  42.       if [ -z "`grep ${docfile} ${TMPDIR}/.book_files.$$`" ] ; then
  43.         echo $docfile
  44.       fi
  45.     done
  46.  
  47.     echo "\nChecking for missing .sgm files..."
  48.     for file in `cat ${TMPDIR}/.book_files.$$` ; do
  49.       sgmfile=`echo $file | sed 's/\.doc/\.sgm/'`
  50.       if [ -z "`ls ${sgmfile} 2> /dev/null`" ] ; then
  51.         echo $file
  52.       fi
  53.     done
  54.  
  55.     echo "\nChecking for extra .sgm files..."
  56.     for file in `/bin/ls *.sgm` ; do
  57.       filename=`basename $file`
  58.       if [ -z "`grep ${filename} ${TMPDIR}/.valid_sgm_files.$$`" ] ; then
  59.         echo $filename
  60.       fi
  61.     done
  62.  
  63.     echo "\nChecking for possible other extra files/dirs..." 
  64.     /bin/ls -1 | sed '/^online$/d' | sed '/^orig$/d' | sed '/^print$/d' | sed '/^.*\.doc$/d' | sed '/^.*\.sgm$/d' | sed '/^Makefile$/d' | sed '/^prod$/d' | sed '/^RCS$/d' | sed '/^help$/d' | sed '/^.*\.mif$/d' | sed '/^.*\.err$/d' | sed '/^.*\.rpt$/d' | sed '/^.*\.backup$/d' | sed '/^localfigrules$/d' | sed '/^books$/d' | sed '/^booklist.txt$/d' | sed '/^.*\.idx$/d' | sed '/^.*\.sgml$/d' | sed '/^.*\.book$/d' | sed '/^EndPart$/d'
  65.  
  66.     # check help refs
  67.     if [ -d help ] ; then
  68.       echo "\nChecking help references (this may take a moment)..."
  69.       for helpmap in `/bin/ls help/*.helpmap` ; do
  70.         valid_helpmap="F"
  71.         for helptopic in `cat $helpmap | sed 's/^\([^;]*;\)\([^;]*;\)\([^;]*;\)\([^;]*;\)\([^;]*\);.*$/\5/' | sed '/#.*/d'`; do
  72.           if [ -z "`grep ${helptopic} $valid_sgm_files`" ] ; then
  73.             echo "$helptopic in `basename $helpmap` does not exist in any valid sgm file"
  74.           else
  75.             valid_helpmap="T"
  76.           fi
  77.         done
  78.         if [ $valid_helpmap = "F" ] ; then
  79.           echo "WARNING: `basename $helpmap` does not contain any valid entries"
  80.         fi
  81.       done
  82.     fi
  83.  
  84.     # pull out refs in doc files to figs in print dir
  85.     echo "\nworking on fig refs\c"
  86.     for file in `cat ${TMPDIR}/.book_files.$$ | grep doc` ; do (strings $file | grep "<c>print<c>" | sed 's/.*<c>\(.*\)<U>.*/\1/' >> ${TMPDIR}/.figlist.$$ ; echo ".\c" ) ; done
  87.     rm ${TMPDIR}/.book_files.$$
  88.  
  89.     # look for figs in Makefile, but not in orig
  90.     echo "\n\nChecking for fig files in Makefile, but not in orig..."
  91.     if [ -f ${TMPDIR}/.figs_make.$$ ] ; then rm ${TMPDIR}/.figs_make.$$ ; fi
  92.     touch ${TMPDIR}/.figs_make.$$
  93.     awk '/^PRINT_BW/,/[^\\]$/' Makefile | sed 's/^PRINT_BW *= *//' | sed s'/\\$//' | sed 's/\.rgb/\.bw/g' >> ${TMPDIR}/.figs_make.$$
  94.     awk '/^PRINT_COLOR/,/[^\\]$/' Makefile | sed 's/^PRINT_COLOR *= *//' | sed s'/\\$//' | sed 's/\.rgb/\.clr/g' >> ${TMPDIR}/.figs_make.$$
  95.     awk '/^PostScript/,/[^\\]$/' Makefile | sed 's/^PostScript *= *//' | sed s'/\\$//' >> ${TMPDIR}/.figs_make.$$
  96.     for file in `cat ${TMPDIR}/.figs_make.$$` ; do
  97.       fullpath=orig/`echo $file | sed 's/\.bw/\.rgb/' | sed 's/\.clr/\.rgb/'`
  98.       if [ -z "`ls $fullpath 2> /dev/null`" ] ; then 
  99.         echo $file
  100.       fi
  101.     done
  102.  
  103.     # look for figs in orig, but not in Makefile
  104.     echo "\n\nChecking for fig files in orig, but not in Makefile..."
  105.     for file in `/bin/ls orig` ; do
  106.       if [ -z "`grep $file Makefile 2> /dev/null`" ] ; then echo $file ; fi
  107.     done
  108.  
  109.     # compare ref'd figs against figs in Makefile
  110.     echo "\nChecking for fig files in the Makefile, but not ref'd in valid .doc's..."
  111.     for file in `cat ${TMPDIR}/.figs_make.$$` ; do
  112.       if [ -z "`grep \"^${file}$\" ${TMPDIR}/.figlist.$$`" ] ; then
  113.         echo $file
  114.       fi
  115.     done
  116.     rm ${TMPDIR}/.figs_make.$$
  117.  
  118.     # if there are any refs to figs in the print dir
  119.     if [ ! -s ${TMPDIR}/.figlist.$$ ] ; then
  120.       echo "no imported figures in doc files\n"
  121.       rm ${TMPDIR}/.figlist.$$
  122.     else
  123.  
  124.       # if there's a print dir
  125.       if [ ! -d print ] ; then
  126.         echo "no print dir"
  127.       else 
  128.  
  129.         echo "\nChecking for figs in print, but not ref'd in valid .doc's..."
  130.         for file in `/bin/ls print` ; do
  131.           if [ -z "`grep $file ${TMPDIR}/.figlist.$$`" ] ; then
  132.             echo $file | sed '/^RCS$/d'
  133.           fi
  134.         done
  135.  
  136.         echo "\nChecking for files referenced in valid .doc's, but not in print/..."
  137.         for file in `cat ${TMPDIR}/.figlist.$$` ; do
  138.           if [ -z "`ls print/${file} 2> /dev/null`" ] ; then
  139.           echo $file
  140.           fi
  141.         done
  142.         echo
  143.       fi
  144.       rm ${TMPDIR}/.figlist.$$
  145.     fi # if there are any imported figures
  146.   fi  # if there are any .docs listed in the Makefile
  147. fi  # if there is a Makefile 
  148.  
  149. # if there's sgms and an online dir
  150. if [ -s ${TMPDIR}/.valid_sgm_files.$$ -a -d online ] ; then
  151.  
  152.   echo "Checking for figs in online not ref'd in valid sgm's..."
  153.   for file in `/bin/ls online` ; do
  154.     if [ -z "`grep $file $valid_sgm_files`" ] ; then
  155.       echo $file | sed '/^RCS$/d'
  156.     fi
  157.   done
  158.  
  159.   echo "\nChecking for files referenced in valid sgm's, but not in online/..."
  160.   for file in `grep "GRAPHIC FILE=" $valid_sgm_files | sed 's/^.*GRAPHIC FILE=\"\([^"]*\)\".*$/\1/'` ; do
  161.     if [ -z "`ls online/${file} 2> /dev/null`" ] ; then
  162.     echo $file
  163.     fi
  164.   done
  165.  
  166. else
  167.   echo "no .sgm's present, or no online dir"
  168. fi
  169. rm ${TMPDIR}/.valid_sgm_files.$$
  170.